package keeto.com.vn.bms.utils;

import keeto.com.vn.bms.config.IBMSConfig;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class BMSSharedPreferences implements IBMSConfig {

	private  SharedPreferences preferences;

	public BMSSharedPreferences(Context context) {
		preferences = context.getSharedPreferences(IBMSConfig.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
	}

	public String getUserLoginName(Context context) {
		return preferences.getString(IBMSConfig.USER_LOGIN_NAME, "");
	}

	public  void setUserLoginName(String name){
		Editor editor = preferences.edit();
		editor.putString(IBMSConfig.USER_LOGIN_NAME, name);
		editor.commit();
	}

	public  String getUserLoginPassword(Context context) {
		return	preferences.getString(IBMSConfig.USER_LOGIN_PASSWORD, "");
	}
	
	public void setUserFullName(String fullname){
		Editor editor = preferences.edit();
		editor.putString(IBMSConfig.USER_LOGIN_FULLNAME, fullname);
		editor.commit();
	}
	public  String getUserLoginFullName(Context context) {
		return	preferences.getString(IBMSConfig.USER_LOGIN_FULLNAME, "");
	}
	
	public void setCaseGroup(String caseGroup){
		Editor editor = preferences.edit();
		editor.putString(IBMSConfig.DOCTOR_LOGIN_CASE_GROUP, caseGroup);
		editor.commit();
	}
	public  String getCaseGroup(Context context) {
		return	preferences.getString(IBMSConfig.DOCTOR_LOGIN_CASE_GROUP, "");
	}
	public void setGroupID(String caseGroup){
		Editor editor = preferences.edit();
		editor.putString(IBMSConfig.GROUP_ID, caseGroup);
		editor.commit();
	}
	public  String getGroupID(Context context) {
		return	preferences.getString(IBMSConfig.GROUP_ID, "");
	}

	public  void setUserLoginPassword(String password){
		Editor editor = preferences.edit();
		editor.putString(IBMSConfig.USER_LOGIN_PASSWORD, password);
		editor.commit();
	}


	public  boolean getRememberCb(Context context) {
		return  preferences.getBoolean(IBMSConfig.USER_LOGIN_CHECKBOX, false);
	}

	public  void setRememberCb( boolean rememberCb) {
		Editor editor = preferences.edit();
		editor.putBoolean(IBMSConfig.USER_LOGIN_CHECKBOX, rememberCb);
		editor.commit();
	}

	public  int getUserPermission(Context context) {
		return preferences.getInt(IBMSConfig.USER_PERMISSION, 0);
	}

	public  void setUserPermission(int per){
		Editor editor = preferences.edit();
		editor.putInt(IBMSConfig.USER_PERMISSION, per);
		editor.commit();
	}
	public String getUserAuthKey(Context context) {
		return preferences.getString(IBMSConfig.USER_AUTHKEY, "");
	}

	public  void setUserAuthKey(String name){
		Editor editor = preferences.edit();
		editor.putString(IBMSConfig.USER_AUTHKEY, name);
		editor.commit();
	}
	public int getTypeKeyUser(Context context) {
		return preferences.getInt(IBMSConfig.TYPE_KEY_USER, 0);
	}

	public  void setTypeKeyUser(int keyUser){
		Editor editor = preferences.edit();
		editor.putInt(IBMSConfig.TYPE_KEY_USER, keyUser);
		editor.commit();
	}

	public  int getStartNotify(Context context) {
		return  preferences.getInt(IBMSConfig.BMS_NOTIFICATION, 0);
	}

	public  void setStartNotify( int timestart) {
		Editor editor = preferences.edit();
		editor.putInt(IBMSConfig.BMS_NOTIFICATION, timestart);
		editor.commit();
	}
	
	public String getUserID(Context context) {
		return preferences.getString(IBMSConfig.USER_ID, "");
	}

	public  void setUserID(String userId){
		Editor editor = preferences.edit();
		editor.putString(IBMSConfig.USER_ID, userId);
		editor.commit();
	}
	public void clear(){
		setStartNotify(0);
		setTypeKeyUser(0);
		setUserFullName("");
		setUserPermission(0);
		setUserID("");
		setUserAuthKey("");
		setCaseGroup("");
		setGroupID("");
		
	}
	
}
